﻿//明星个人页状态
Pui.starShowData = function(json) {
	var star_price=star_status=star_step='';//明星身价、状态、等级、经纪人经验
	star_price=parseInt(json[0].data[0]);

	$('#star_data .price').html(star_price);
	$('#star_data .status').html(Pui.star.status(parseInt(json[0].data[1])));
	$('#star_data .step').html(Pui.star.level(star_price, 1));
	
	var nobj = "#agent_" +json[0].id;
	//alert(isFans);
	//经纪人判断
	if(json[0].data[4]>0){
		//经纪人图片
		var str="<a href='"+json[0].data[6]+"'taget=_blank><img src='"+json[0].data[7]+"'/></a>";
		$('#agend_photo').html(str);
		
		if(parseInt(json[0].data[4])==parseInt(_user.uid)) {
			$($("div.sA_name").find("span")[1]).html("<a target=\"_blank\" href=http://www.pomoho.com/manage/starhome.aspx?starid="+json[0].id+">管理明星</a>");
			$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
			//alert($($("div.sA_name").find("span")[1]).html());
		}
		else
		{
			if (starType == 1) {
				$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
				$($("div.sA_name").find("span")[1]).html("<a href=\"javascript:Pui.star.trade(1, " +json[0].id+ ", function(s) {starinit()});\">从Ta手里抢过来</a>");
			} else {
				$($("div.sA_name").find("span")[1]).html("官方明星不能购买");
				$($("div.sA_name").find("span")[1]).attr("class", "sA_ma sA_ma_no");
			}
		}
		$($("div.sA_name").find("span.cname_n")).html(json[0].data[5]);
		//调用showData,显示明星经验值,括号里面是第二个数据接口，用于显示经纪人经验值
		Pui.loadScript("http://live.pomoho.com/getxmldata.aspx?type=1&ids="+json[0].data[4]+"");
	}
	else {
		var text='没有经纪人';
		var img="<img src='http://static.pomoho.com/pics/user_default.gif'>";//没有经纪人默认图片
		if (starType == 1) {
			$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
			$($("div.sA_name").find("span")[1]).html("<a href=\"javascript:Pui.star.trade(1, " +json[0].id+ ", function(s) {starinit()});\">我要购买他</a>");
		} else {
			$($("div.sA_name").find("span")[1]).html("官方明星不能购买");
			$($("div.sA_name").find("span")[1]).attr("class", "sA_ma sA_ma_no");
		}
		$('#agend_photo').html(img);
		$($("div.sA_name").find("span.cname_n")).html(text);
	}
	//经纪人姓名
	if (eval(isFans)) {
		$("#addfans").html("<a href=\"javascript:Pui.star.exitfans("+json[0].id+", function(s) {starinit()});\">退出Ta的粉丝圈</a>");
		if (eval(json[0].data[3])) {
			$('#getexp').show();
		} else {
			$('#getexp').hide();
		}
	} else {
		$("#addfans").html("<a href=\"javascript:Pui.star.addfans("+json[0].id+", function(s) {starinit()})\">加入Ta的粉丝圈</a>");
		$('#getexp').hide();
	}
};
Pui.ReUrl = function (json) {
	if (_is_login) {
		if ('undefined' == typeof(isFans)) return;
		if (eval(isFans)) {
			window.open(json.url);
		} else {
			if (window.confirm('您不是该明星的粉丝，需加入Ta的粉丝圈，财富才会增加！现在加入吗？')) {
				Pui.star.addfans(json.starId, function(s) {
					if ('undefined' == typeof(s) || 'undefined' == typeof(s.ret) || s.ret != 1) {
						if (json.url.indexOf("post") != -1) {
							window.open(json.url);
							return;
						}
						if (json.url.indexOf("upload") != -1) {
							window.open("http://www.pomoho.com/upload");
						} else {
							window.open("http://www.pomoho.com/ui/editmv.aspx");
						}
						return;
					} else {
						window.open(json.url);
						Pui.star.appcallback = null;
					}
				});
			} else {
				if (json.url.indexOf("post") != -1) {
					window.open(json.url);
					return;
				}
				if (json.url.indexOf("upload") != -1) {
					window.open("http://www.pomoho.com/upload");
				} else {
					window.open("http://www.pomoho.com/ui/editmv.aspx");
				}
			}
		}
	} else {
		Pui.star.json = json;
		Pui.star.showlogin(Pui.ReUrl);
	}
};
Pui.star = {
	json:null,
	callback:null,
	appcallback:null,
	invoker:function(s){Pui.star.invoker_callback(s);},
	invoker_callback:function(s) {
		if (jQuery.isFunction(this.appcallback)) {
			this.json = 'undefined' == typeof(s) ? this.json : s;
			this.appcallback(this.json);
		}
		if (jQuery.isFunction(this.callback)) {
			this.json = 'undefined' == typeof(s) ? this.json : s;
			this.callback(this.json);
		}
		this.appcallback = null;
		this.callback = null;
		this.json = null;
	},
	status:function(s) {
		switch(s){
			case 0:return '自由身';
			case 1:return '采访中';
			case 2:return '走秀中';
			case 3:return '正在与粉丝见面';
			case 4:return '正在开演唱会';
			case 5:return '正在拍电影';
		}
	},
	level:function(val, type) {
		if (type == 1) {
			if (val >= 100000) { return '一线明星'; }
			else if ((val >= 50000) && (val < 100000)) { return '二线明星'; }
			else if ((val > 10000)&&(val < 50000)) { return '三线明星'; }
			else { return '新人'; }
		}
		else {
			if (val >= 1000000) { return '金牌经纪人'; }
			else if((val >= 100000) && (val < 1000000)) { return '银牌经纪人'; }
			else if((val >= 10000) && (val < 100000)) { return '铜牌牌经纪人'; }
			else{ return '新手经纪人'; }
		}
	},
	readdfans:function(json) {
		this.addfans(json.starId, json.callback);
	},
	addfans:function(starId, appcallback) {
		appcallback = 'undefined' == typeof(appcallback) || '' == appcallback ? null: appcallback;
		if (!_is_login) {
			this.json = {starId:starId, callback:appcallback};
	        this.appcallback = Pui.star.readdfans;
	        this.showlogin();
	    }
	    else {
			this.appcallback = appcallback;//this.invoker
			Pui.loadScript("http://www.pomoho.com/combo/combointerface.aspx?callback=Pui.star.addfans_callback&appcallback=" +this.invoker+ "&otype=addfans&objid=" + _user.uid + "&starid=" + starId);
			//Pui.loadScript("http://www.pomoho.com/combo/combointerface.aspx?callback=Pui.star.addfans_callback&appcallback=" +appcallback+ "&otype=addfans&objid=" + _user.uid + "&starid=" + starId);
			//this.addfans_callback({ret:1, type:'addfans', userId:12345, starId:starId, comboId:12345, callback:appcallback});
		}
	},
	addfans_callback:function(json) {
		if ('undefined' == typeof(json) || 'undefined' == typeof(json.ret)) {
			alert("调用接口返回错误数据类型！");
			return;
		}
		switch (json.ret) {
			case 1:
				if ('undefined' != typeof(isFans)) isFans = true;
				$('#getexp').show();
				$('span#addfans').html("<a href=\"javascript:Pui.star.exitfans(" + json.starId + ", function(s) {starinit()});\">退出她的粉丝圈</a>");
				alert('加入成功！');
				break;
			case 2:
				$('#getexp').hide();
				alert('加入失败,您加入的粉丝圈已经超过10个！');
				break;
			case 3:
				if ('undefined' != typeof(isFans)) isFans = true;
				alert('你已经是粉丝,无需重新加入！');
				$('#getexp').show();
				$('span#addfans').html("<a href=\"javascript:Pui.star.exitfans(" + json.starId + ", function(s) {starinit()});\">退出她的粉丝圈</a>");
				break;
			case -1:
				alert('操作异常，请稍后再试！异常信息：'+json.msg);
				break;
		}
		if ('undefined' != typeof(json.callback)) {
			json.callback(json);
		}
	},
	exitfans:function(starId, appcallback) {
		appcallback = 'undefined' == typeof(appcallback) || '' == appcallback ? null: appcallback;
		this.appcallback = appcallback;//this.invoker
		if (_is_login) {
			Pui.loadScript("http://www.pomoho.com/combo/combointerface.aspx?callback=Pui.star.exitfans_callback&appcallback=" + this.invoker + "&otype=exitfans&objid="+_user.uid+"&starid=" + starId);
		} else {
			this.exitfans_callback({ ret:-1, type:'exitfans', userId:-1, starId:starId, comboId:-1, callback:this.invoker });
		}
	},
	exitfans_callback:function(json) {
		if ('undefined' == typeof(json) || 'undefined' == typeof(json.ret)) {
			alert("调用接品返回错误数据类型！");
			return;
		}
		switch (json.ret) {
			case 1:
				alert('成功退出粉丝圈');
				$('#getexp').hide();
				$('span#addfans').html("<a href=\"javascript:Pui.star.addfans(" + json.starId + ", Pui.star.addfans_callback);\">加入她的粉丝圈</a>");
				break;
			case 2:
				alert('你是该明星的经纪人，请释放你的明星以后再退出！');
				break;
			case 3:
				alert('你加入该明星的粉丝圈还没有超过24小时,不能退出！');
				break;
			case -1:
				alert('操作异常，请稍后再试！异常信息：'+json.msg);
				break;
		}
		if ('undefined' != typeof(json.callback)) {
			json.callback(json);
		}
	},
	getexperience:function(starId, appcallback) {
		appcallback = 'undefined' == typeof(appcallback) || '' == appcallback ? null: appcallback;
		if (!_is_login) {
	        this.showlogin();
	    } else {
			this.appcallback = appcallback;//this.invoker
			Pui.loadScript("http://live.pomoho.com/getexperience.aspx?callback=Pui.star.getexperience_callback&appcallback=" + this.invoker + "&uid=" + _user.uid + "&sid=" + starId);
			//callback({ ret:-1, type:'exitfans', userId:-1, starId:starId, comboId:-1 });
		}
	},
	getexperience_callback:function(json) {
		if ('undefined' == typeof(json) || 'undefined' == typeof(json.ret)) {
			alert("调用接口返回错误数据类型！");
			return;
		}
		switch(json.ret){
			case 1:
				alert('你已经领取了10点经验！');
				$('#getexp').hide();
				break;
			case 2:
				alert('领取失败,不可以重复领取');
				$('#getexp').hide();
				break;
			case 3:
				Pui.star.callback = Pui.star.appcallback;
				if (window.confirm('您不是该明星的粉丝，需加入才领取！现在加入吗？')) {
					this.addfans(json.starId, function(s) {
						if ('undefined' == typeof(s) || 'undefined' == typeof(s.ret) || s.ret != 1) {
							return;
						} else {
							Pui.star.getexperience(s.starId, Pui.star.callback);
						}
					});
				}
				return;
			case -1:
				alert('操作异常，请稍后再试！异常信息：'+json.msg);
				break;
		}
		if ('undefined' != typeof(json.callback)) {
			json.callback(json);
		}
	},
	retrade:function(json) {
		this.trade(json.type, json.starId, json.callback);
	},
	trade:function(type, starId, appcallback) {
		appcallback = 'undefined' == typeof(appcallback) || '' == appcallback ? null: appcallback;
		if (!_is_login) {
	        this.showlogin();
	        this.json = {type:type, starId:starId, callback:appcallback};
	        this.appcallback = Pui.star.retrade;
	    } else {
			this.appcallback = appcallback;
			Pui.loadScript("http://live.pomoho.com/starinterface.aspx?callback=Pui.star.trade_callback&appcallback=" +this.invoker+ "&type=" +type+ "&uid="+_user.uid+"&sid="+starId+"");
			//Pui.loadScript("http://live.pomoho.com/starinterface.aspx?callback=Pui.star.trade_callback&appcallback=" +appcallback+ "&type=" +type+ "&uid="+_user.uid+"&sid="+starId+"");
			//this.trade_callback({ ret:5, type:type, userId:_user.uid, starId:starId, comboId:-1, callback:appcallback, msg:'aaa' });
		}
	},
	trade_callback:function(json) {
		if ('undefined' == typeof(json) || 'undefined' == typeof(json.ret)) {
			alert("调用接口返回错误数据类型！");
			return;
		}
		switch(json.ret){
			case 1:
				if (json.type == 1) {
					alert('购买成功！');
				} else {
					alert('释放成功！');
				}
				break;
			case 2:
				alert('此时的明星状态或者用户状态无效，无法进行当前操作！');
				break;
			case 3:
				alert('您当前余额不足，不能购买！');
				break;
			case 4:
				alert('您没有达到经纪人等级，不能购买！');
				break;
			case 5:
				//不是明星粉丝,提示是否加入,加入成功后用全局变量中转回调函数
				if (window.confirm('您不是该明星的粉丝，需加入才能购买！现在加入吗？')) {
					Pui.star.callback = Pui.star.appcallback;
					this.addfans(json.starId, function(s) {
						if ('undefined' == typeof(s) || 'undefined' == typeof(s.ret) || s.ret != 1) {
							return;
						} else {
							Pui.star.trade(1, s.starId, Pui.star.callback);
						}
					});
				}
				return;
			case 6:
				alert('您不是该明星的经纪人,不能释放！');
				break;
			case 7:
				alert('您已达到等级最多拥有明星数！');
				break;
			case 8:
				alert('明星正在活动中,不能释放！');
				break;
			case 9:
				alert('明星一天只能买卖两次！');
				break;
			case 10:
				alert('官方明星不能买卖！');
				break;
			case 11:
				alert('购买明星两天后才能释放！');
				break;
			case 12:
				alert('您已经是该明星的经纪人了！');
				break;
			case -1:
				alert('操作异常，请稍后再试！异常信息：'+json.msg);
				break;
		}
		if ('undefined' != typeof(json.callback)) {
			json.callback(json);
		}
	},
	showlogin:function(callback) {
		flag = 10;
	    Pui.newSH.loginfo();
	    Pui.star.appcallback = 'undefined' == typeof(callback) ? Pui.star.appcallback : callback;
	},
	showupdown:function(json) {
		if (undefined == typeof(json)) return;
		$(json).each(function(){
			if ('undefined' == typeof(this.data)) return;
			var cname = parseInt($("#star_" + this.id+" input:hidden").val()) < this.data[0] ? "Dup" : "Ddown";
			$("#star_" + this.id).attr("class", cname);
		});
	},
	showsearchret:function(json) {
		if (undefined == typeof(json)) return;
		$(json).each(function(i){
			if ('undefined' == typeof(this.data)) return;
			//alert(.html());
			var star_price=parseInt(json[i].data[0]);
			var level = Pui.star.level(star_price, 1);
			$("#" + json[i].type + "_" + json[i].id).find("span.level").html("等级：" + level);
			$("#" + json[i].type + "_" + json[i].id).find("span.view").html("身价：" + star_price);
		});
	},
	showdata:function(json) {
		//0-price;1-status
		if ('undefined' == typeof(json)) return;
		$(json).each(function(){
			if ('undefined' == typeof(this.data)) return;
			$($('#' + this.type + '_' +this.id).find("span[class='view']")).html(this.data[0]);
			var opt = "";
			var status = "";
			
			if (parseInt(this.data[1]) == 0) {
				if (parseInt(this.data[4]) > 0) {
					if(parseInt(this.data[4]) != parseInt(_user.uid)) {
						opt = "<span class=\"Tobuy\"><a id=\"opt_"+this.id+"\" href=\"javascript:Pui.star.trade(1, " + this.id + ", null);\">抢</a></span>";
					}
				} else {
					opt = "<span class=\"Tobuy\"><a id=\"opt_"+this.id+"\" href=\"javascript:Pui.star.trade(1, " + this.id + ", null);\">购买</a></span>";
				}
				status = Pui.star.status(this.data[1]); 
			} else { 
				if (parseInt(this.data[4]) > 0 && parseInt(this.data[4]) != parseInt(_user.uid)) {
					opt = "<span class=\"Tobuy\"><a id=\"opt_"+this.id+"\" href=\"javascript:Pui.star.trade(1, " + this.id + ", null);\">抢</a></span>";
				}
				status = "<span class=\"Fstar\">" + Pui.star.status(this.data[1]) + "</span>";
			}
			$($('#' + this.type + '_' +this.id).find("dd.status")).html(opt + "状态：" + status);
		});
	},
	showstardata:function(json) {
		var star_price=star_status=star_step='';//明星身价、状态、等级、经纪人经验
		star_price=parseInt(json[0].data[0]);

		$('#star_data .price').html(star_price);
		$('#star_data .status').html(Pui.star.status(parseInt(json[0].data[1])));
		$('#star_data .step').html(Pui.star.level(star_price, 1));
		
		var nobj = "#agent_" +json[0].id;
		
		//经纪人判断
		if(json[0].data[4]>0){
			//经纪人图片
			var str="<a href='http://home.pomoho.com/"+json[0].data[6]+".shtml' taget=_blank><img src='"+json[0].data[7]+"'/></a>";
			$('#agend_photo').html(str);
			
			if (parseInt(json[0].data[4]) == parseInt(_user.uid)) {
				$($("div.sA_name").find("span")[1]).html("<a target=\"_blank\" href=http://www.pomoho.com/manage/starhome.aspx?starid="+json[0].id+">管理明星</a>");
				$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
			} else {
				//$($("div.sA_name").find("span.sA_ma")).html("<a href=\"javascript:Pui.star.trade(1, " +json[0].id+ ", null);\">从Ta手里抢过来</a>");
				if (starType == 1) {
					$($("div.sA_name").find("span")[1]).html("<a href=\"javascript:Pui.star.trade(1, " +json[0].id+ ", function(s) {starinit()});\">从Ta手里抢过来</a>");
					$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
				} else {
					$($("div.sA_name").find("span")[1]).html("官方明星不能购买");
					$($("div.sA_name").find("span")[1]).attr("class", "sA_ma sA_ma_no");
				}
			}
			$($("div.sA_name").find("span.cname_n")).html(json[0].data[5]);
			//调用showData,显示明星经验值,括号里面是第二个数据接口，用于显示经纪人经验值
			Pui.loadScript("http://live.pomoho.com/getxmldata.aspx?type=1&ids="+json[0].data[4]+"");
		}
		else {
			var text='没有经纪人';
			var img="<img src='http://static.pomoho.com/pics/user_default.gif'>";//没有经纪人默认图片
			if (starType == 1) {
				$($("div.sA_name").find("span")[1]).html("<a href=\"javascript:Pui.star.trade(1, " +json[0].id+ ", function(s) {starinit()});\">我要购买他</a>");
				$($("div.sA_name").find("span")[1]).attr("class", "sA_ma");
			} else {
				$($("div.sA_name").find("span")[1]).html("官方明星不能购买");
				$($("div.sA_name").find("span")[1]).attr("class", "sA_ma sA_ma_no");
			}
			$('#agend_photo').html(img);
			$($("div.sA_name").find("span.cname_n")).html(text);
		}
		//经纪人姓名
		//alert(eval(json[0].data[2]));
		if (eval(isFans) || eval(json[0].data[2])) {
			$("#addfans").html("<a href=\"javascript:Pui.star.exitfans("+json[0].id+", null);\">退出Ta的粉丝圈</a>");
			isFans = eval(json[0].data[2]);
			if (eval(json[0].data[3])) {
				$('#getexp').show();
			} else {
				$('#getexp').hide();
			}
		} else {
			$("#addfans").html("<a href=\"javascript:Pui.star.addfans("+json[0].id+", null)\">加入Ta的粉丝圈</a>");
			$('#getexp').hide();
		}
	}
};

Pui.showData = function(json){
	if ('undefined' == typeof(json[0]) || 'undefined' == typeof(json[0].data) || 9 > $(json[0].data).size()) return;
	$(json).each(function(i){
		if ('undefined' == typeof(json[i]) || 'undefined' == typeof(json[i].data) || 9 > $(json[i].data).size()) {}
		else {
			var agent_jy = parseInt(json[i].data[9]);//用户经验值
			var desc = Pui.star.level(agent_jy, 2);
			var obj = i < 2 ? $('#' + json[i].type + '_' +json[i].id).find("span[class^=cname_n]") : $('#' + json[i].type + '_' +json[i].id).find("span[class^=cname_m]");
			//var obj2 = $('#' + json[i].type + '_' +json[i].id).find("span[class^=cname_m2]");
			var className = "";
			if(agent_jy >= 1000000) { 
				className = "n1"; 
			}
			else if((agent_jy >= 100000) && (agent_jy < 1000000)) { 
				className = "n2";
			}
			else if((agent_jy >= 10000) && (agent_jy < 100000)) { 
				className = "n3";
			}
			else { 
				className = "";
			}
			$(obj).addClass(className).end().attr('title', desc); 
			//alert($($('#' + json[i].type + '_' +json[i].id).find("span[class='view']")).html());
			$("div.sA_name").find("span.cname_n").addClass(className).end().attr("title", desc);
			$($('#' + json[i].type + '_' +json[i].id).find("span[class='view']")).html("&nbsp;" +json[i].data[10]);
			
	    }
	});
}
//明星话题加载
Pui.c = {
	navIndex:function() {},
	topic:function(json) {
		var str = "";
		$(json).each(function(i) {
		    str+="<tr><td>"+this.hits+"</td>";
			str+="<td>"+this.answer+"</td>";
			str+="<td><a href=http://post.pomoho.com/topicview.aspx?postid="+this.postId+"&topicid="+this.topicId+" target='_blank'>"+this.title+"</a></td>";
			str+="<td><a href=http://home.pomoho.com/"+this.spaceurl+".shtml target='_blank'>"+this.author+"</a></td>";
			str+="<td>"+this.timer+"</td></tr>"
		});
		$('table #tbody').html(str);}

}
//加载粉丝动态滚动
Pui.loadPublicNews = function(json) {
    var linklist = "";
    $(json).each(function(i) {
        linklist+="<li>"+this[0]+"</li>";
    });
    $('ul#fansADlist').html(linklist);
}
//粉丝动态滚动
var int;
function AutoScroll(obj){$(obj).find("ul#fansADlist").animate({marginTop:"-30px"},500,function(){$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);});}
function upScroll(){int=setInterval('AutoScroll("#fansAD")',3000);}
function stopScroll(){clearInterval(int)}
$(function(){upScroll();$("ul#fansADlist li a").hover(function(){stopScroll();},function(){upScroll();})});

/*登录*/
Pui.newSH={init:function(){_user={uid:0,nick:'',spacename:'',newmsg:0};_is_login=false;var n=Pui.cookie('LoginInfo');if(n){var arr=n.split('$***$');_user={uid:arr[0].replace('LoginInfo=',''),nick:arr[1],spacename:arr[2],newmsg:0,spaceurl:arr[3]};_is_login=true;this.islogin();}else{this.unlogin();};this.doSearch();},
unlogin:function(){var str='';str+='<li class="s"><a target="_blank" class="f" title="返回首页" href="http://www.pomoho.com/">首页</a></li>';str+='<li class="s"><a class="f" title="登录" href="javascript:Pui.newSH.loginfo()">登录</a></li>';str+='<li class="s logout"><a class="f" title="注册" href="http://www.pomoho.com/ui/login.aspx" target="_blank">注册</a></li>';$("#TopNav").html(str);$('#getexp').hide();},
islogin:function(){var t_time=this.localTime();var str='';str+='<li class="s"><a target="_blank" title="返回首页" href="http://www.pomoho.com/">首页</a></li>';str+='<li class="s">'+t_time+',<a class="user" target="_blank" href="http://home.pomoho.com/'+_user.spaceurl+'.shtml" >'+_user.nick+'</a></li>';str+='<li class="s"><a class="count" title="你的帐户" href="http://www.pomoho.com/manage/index.aspx" target="_blank" >帐户&nbsp;&nbsp;&nbsp;&nbsp;</a>';str+='   <div class="d s3">';str+='     <ul>';str+=' <li><a class="d_item" title="我的视频" href="http://www.pomoho.com/manage/managevideo.aspx" target="_blank" >我的视频</a></li>';str+='<li><a class="d_item" title="我的订阅" href="http://www.pomoho.com/manage/subscribevblog.aspx" target="_blank" >我的订阅</a></li>';str+=' <li><a class="d_item" title="我的收藏" href="http://www.pomoho.com/manage/managevideo.aspx?type=favs" target="_blank" >我的收藏</a></li>';str+=' <li><a class="d_item" title="我的相册" href="http://www.pomoho.com/manage/managealbum.aspx" target="_blank" >我的相册</a></li>';str+=' </ul>';str+='     <div class="m1"><a title="更多管理" href="http://www.pomoho.com/manage/index.aspx" target="_blank" >更多..&nbsp;&nbsp;</a></div>';str+='   </div>';str+=' </li>';str+=' <li class="s"><a title="你的消息" href="http://www.pomoho.com/manage/messagelist.aspx?type=1" target="_blank" >消息</a><span>(0)</span>';str+='<div class="d s2">';str+=' <div class="title"><div class="d_video">主题</div><div class="d_author">消息来源</div></div>';str+='<ul>';str+=' </ul>';str+=' <div class="m"><a title="全部消息" href="http://www.pomoho.com/manage/messagelist.aspx?type=1" target="_blank" >全部消息&gt;&gt;</a></div>';str+='   </div>';str+=' </li>';str+=' <li class="logout"><a title="退出登录" href="http://www.pomoho.com/ui/logout.aspx?AfterLoginReturnURL='+window.location+'" >退出</a></li>';$("#TopNav").html(str);this.SH();Pui.loadScript("http://notice.pomoho.com/loadmessage2.0.aspx");},
SH:function(){var tim;$("#TopNav .s").hover(function(){$(this).siblings().find(".d").hide();$(this).find(".d").show();clearTimeout(tim);},function(){tim=setTimeout(overDiv,500);function overDiv(){$("#TopNav").find(".d").slideUp();}});},localTime:function(){var time=new Date();var hour=time.getHours();var t_time=($.browser.msie)?String(time).split(" ")[3].substr(0,5):String(time).split(" ")[4].substr(0,5);switch(hour){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t_time='早上好';break;case 8:case 9:case 10:case 11:t_time='上午好';break;case 12:t_time='中午好';break;case 13:case 14:case 15:case 16:case 17:t_time='下午好';break;case 18:case 19:case 20:case 21:case 22:case 23:t_time='晚上好';break;}
return t_time;},Msginit:function(jsonMsg){
var str='';var len=jsonMsg.length;if(len<=1)
{var str='<li style="width:100%">您还没有消息</li>';}else{for(var i=1;i<=len-1;i++)
{var msgtypename;switch(jsonMsg[i].msgtype)
{case 1:msgtypename="站内消息"
break;case 2:msgtypename="系统消息"
break;
case 3:msgtypename="公告"
break;}
str+='<li id="msg'+i+'">';if(jsonMsg[i].msgtype!=3){str+='<div class="d_video"><a title="'+jsonMsg[i].msgtitle+'" href="http://www.pomoho.com/manage/readmessage.aspx?receiveid='+jsonMsg[i].msgid+'&rettype=1" target="_blank" >'+jsonMsg[i].msgtitle+'</a></div>';}else{str+='<div class="d_video"><a title="'+jsonMsg[i].msgtitle+'" href="http://www.pomoho.com/manage/readmessage.aspx?bulletinid='+jsonMsg[i].msgid+'&rettype=1" target="_blank" >'+jsonMsg[i].msgtitle+'</a></div>';}
str+='<div class="d_author">'+msgtypename+'</div>';str+='<a class="d_close" title="删除消息" href="javascript:Pui.newSH.Msgdel('+jsonMsg[i].msgid+','+jsonMsg[i].msgtype+','+i+')" ></a> </li>';}}
$("#TopNav .s2 ul").html(str);$("#TopNav .s2").parent().find("span").html("("+jsonMsg[0]+")");},Msgdel:function(msgid,msgtype,num){$("#msg"+num).remove();var Msgurl="http://www.pomoho.com/do/interfaces/delmessage.aspx?messageID="+msgid+"&Userid="+_user.uid+"&messageType="+msgtype;Pui.loadScript(Msgurl);var num=parseInt($("#TopNav .s2").parent().find("span").html().substr(1))-1;if(num<=0)num=0;$("#TopNav .s2").parent().find("span").html("("+num+")");},doSearch:function(e){if(typeof(s)!='undefined')return
else s=1;$("#goSearch").click(function(){var values=$.trim($("#searchGame").val());if(!values){alert("关键字不能为空");$("#searchGame").focus();}else{var param=encodeURIComponent(values.replace(/[\/_]/g,' '));var url="http://search.pomoho.com/videosearch.aspx?_keyword="+param;window.open(url,'_blank');}});},logDiv:function(){var str='';if($.browser.msie)
str+='<iframe id="zhezhao"></iframe>';else
str+='<div id="zhezhao"></div>';str+=' <div id="Prompt" class="prompt">';str+='    <div class="k log_v">';str+='      <div class="meat">';str+='        <div class="close"><img alt="关闭" src="http://static01.pomoho.com/themes/site/default/images/games/close.gif" width="16" height="16" /></div>';str+='        <h3></h3>';str+='        <p class="p2">您的帐号：';str+='          <input id="uidName" type="text" onkeydown="Pui.newSH.submitF(event)" />';str+='        </p>';str+='        <p class="p2">登录密码：';str+='          <input id="uidPwd" type="password" onkeydown="Pui.newSH.submitF(event)" />';str+='          <a href="http://www.pomoho.com/ui/findpassword.aspx" target="_blank">忘记密码</a></p>';str+='        <p class="pbt">';str+='          <input id="btnlog" onclick="return Pui.newSH.login()" class="log" type="button" value="登录" />';str+='          <input id="reg" class="log" type="button" value="注册" />';str+='        </p>';str+='      </div>';str+='    </div>';str+='  </div>';$("body").prepend(str);if($.browser.msie)
{var cw=window.frames['zhezhao'];cw.document.open();cw.document.write('<style type="text/css">body{background:#000;}</style>');cw.document.close();}
$("#Prompt .close img").bind("click",Pui.newSH.closeDiv);$("#reg").click(function(){window.open('http://www.pomoho.com/ui/login.aspx');});},showLogDiv:function(){if(!$("#Prompt").length)
{Pui.newSH.logDiv();}
var doc=document;var docElement=doc.documentElement;var sHeight=docElement.clientHeight;var dH=docElement.scrollHeight>sHeight?docElement.scrollHeight:sHeight;var scH=docElement.scrollTop>=0?(docElement.scrollTop+sHeight/2):sHeight;var h=scH-$("#Prompt").height()/2;var w=docElement.clientWidth/2-$("#Prompt").width()/2;$("#zhezhao").height(dH).show();$("#Prompt").css({top:h,left:w});},loginfo:function(){Pui.newSH.showLogDiv();$("#Prompt").show();$("#Prompt .k")[0].className="k log_v";$('#uidName').focus();if(document.attachEvent){document.attachEvent('onkeyup',Pui.newSH.EXC);}else{document.addEventListener('keyup',Pui.newSH.EXC,false)}},submitF:function(e){var event=window.event||e;if(event.keyCode==13)
$("#btnlog").click();},EXC:function(e){var event=window.event||e;if(event.keyCode==27)
Pui.newSH.closeDiv();},login:function(){var userName=$.trim($("#uidName").val());var pwd=$("#uidPwd").val();if(userName==''||pwd=='')
{alert("用户名或者密码不能为空");return false}else{Pui.newSH.logAjax(userName,pwd);}},closeDiv:function(){$("#Prompt").hide();$("#zhezhao").hide();},logAjax:function(userName,pwd){
$.ajax({url:"http://"+window.location.hostname+"/do/interfaces/sendajaxreq.aspx",dataType:"xmlDocument",type:"post",data:"action=http://www.pomoho.com/ui/logindo.aspx&form_name="+userName+"&form_password="+pwd+"&type=gamelogin&random="+Math.random(),
error:function(){alert('可能网络问题,登录失败,请重试');},
success:function(result){var userlog=eval(result);switch(parseInt(userlog[0].stat)){case-1:alert("登录帐号不存在");break;case-2:alert("用户名或者密码错误,请重试");break;case 1:Pui.newSH.cookie('UserInfo',userlog[1].UserInfo,{path:'/',domain:'.pomoho.com',expires:1/6});
Pui.newSH.cookie('LoginInfo',userlog[2].LoginInfo,{path:'/',domain:'.pomoho.com',expires:1/6});var urlString=window.location.toString().toLowerCase();if(urlString.indexOf("pomoho.com/starzone")!=-1){$('#getexp').show();}if(urlString.indexOf("pomoho.com/combo")!=-1&&(typeof(flag)=='undefined'||flag==null))
{window.location.reload();return}
Pui.newSH.init();
if(typeof(flag)=='undefined'||flag==null)
Pui.newSH.closeDiv();
else if(flag==1)
{Pui.user.haveFriend();flag=null;}
else if(flag==10)
{
	flag=null;Pui.newSH.closeDiv();
	if ("undefined" != typeof(Pui.star.invoker_callback)) {
		Pui.star.invoker_callback();
	}
	Pui.newSH.closeDiv();
}
else if(flag==2)
{Pui.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=2&imdbid="+flvid);flag=null;Pui.newSH.closeDiv();}
else if(flag==3)
{f_addfriend(_userid);flag=null;Pui.newSH.closeDiv();}
else if(flag==4)
{flag=null;Pui.newSH.closeDiv();f_comboInterFace(addPram.otype,addPram.atype,addPram.comboid,_user.uid);Pui.newSH.closeDiv();}
else if(flag==5)
{flag=null;Pui.ReUrl(pathUrl);Pui.newSH.closeDiv();}
break;default:alert("系统错误,请重试，错误代码："+userlog[1].ErrMsg);Pui.newSH.closeDiv();}}});},cookie:function(name,value,options){if(typeof(value)!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+options.path:'';var domain=options.domain?'; domain='+options.domain:'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',name+'='+value,expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=unescape(cookie.substring(name.length+1));break;}}}
return cookieValue;}}};
flag = 10;